import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'
// import father from '../components/father.vue'
import login from '../components/login.vue'
import error from '../components/error.vue'
import child from '../components/child.vue'

const father = () => import('../components/father')
const list = () => import('../components/goodslist')
const details = () => import('../components/goodsdetails')
const layout = () => import('../components/layout')
const center1 = () => import('../components/center1')
const center2 = () => import('../components/center2')
const center3 = () => import('../components/center3')


Vue.use(Router)

export default new Router({
  routes: [
    {
      path:'/father',
      name:'father',
      component:father,
      meta:{
        title:'父组件'
      },
      beforeEnter:(to,from,next)=>{
        console.log('哈哈哈被我抓到了吧');
        next()
      }
    },
    {
      path:'/login',
      name:'login',
      component:login
    },
    {
      path:'/list',
      name:'list',
      component:list
    },
    {
      path:'/details/:name',
      name:'details',
      component:details
    },
    {
      path:'/child',
      name:'child',
      component:child,
      meta:{
        title:'子组件'
      },
      beforeEnter:(to,from,next)=>{
        console.log('哈哈哈被我抓到了吧');
        next()
      }
    },
    {
      path:'*',
      component:error
    },
    {
      path:'*',
      redirect:'/error'
    },
    {
      path:'/layout', 
      component:layout,
      children:[
        {path:'center1',component:center1},
        {path:'center2',component:center2},
        {path:'center3',component:center3}
      ]
    }

  ]
})
